package ru.gelin.android.bells;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class TimerDbOpenHelper extends SQLiteOpenHelper {

    static final String DATABASE_NAME = "timers";
    static final int DATABASE_VERSION = 1;
    static final String TIMER_TABLE = "timer";
    
    static final String ID = "id";
    static final String ENABLED = "enabled";
    static final String START = "start";
    static final String PERIOD_HOURS = "period_hours";
    static final String PERIOD_MINUTES = "period_minutes";
    static final String MESSAGE = "message";
    static final String ALARM = "alarm";
    
    private static final String TIMER_TABLE_CREATE =
                "CREATE TABLE " + TIMER_TABLE + " (" +
                ID + " INTEGER PRIMARY KEY, " +
                ENABLED + " BOOLEAN, " +
                START + " DATETIME, " +
                PERIOD_HOURS + " INTEGER, " +
                PERIOD_MINUTES + " INTEGER, " +
                MESSAGE + " TEXT, " +
                ALARM + " TEXT" +
                ");";

    TimerDbOpenHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(TIMER_TABLE_CREATE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //we have only one (first) version of our database
        //nothing to do here
    }

}
